package com.xdq.spring.service;

import com.xdq.spring.model.Engine;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.UUID;

@Service
@Scope("singleton")
public class EngineProducer {

    private List<Engine> engines = new ArrayList<>();

    public EngineProducer(){
        System.out.println("EngineProducer被实例化了");
    }

    public List<Engine> produces(int count) {
        for (int i = 0; i < count; i++) {
            Engine engine = new Engine();
            engine.setBrand("audi");
            engine.setCreateDate(String.valueOf(System.currentTimeMillis()));
            engine.setSerialNo(UUID.randomUUID().toString());
            engines.add(engine);
        }
        return engines;
    }
}
